package com.team7.happycommunity.personcentor.service.impl;

import com.team7.happycommunity.personcentor.entity.PersonCollectUser;
import com.team7.happycommunity.personcentor.dao.PersonCollectUserDao;
import com.team7.happycommunity.personcentor.service.PersonCollectUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (PersonCollectUser)表服务实现类
 *
 * @author makejava
 * @since 2020-03-22 21:19:30
 */
@Service("personCollectUserService")
public class PersonCollectUserServiceImpl implements PersonCollectUserService {
    @Resource
    private PersonCollectUserDao personCollectUserDao;

    /**
     * 通过ID查询单条数据
     *
     * @param collectUserId 主键
     * @return 实例对象
     */
    @Override
    public PersonCollectUser queryById(Integer collectUserId) {
        return this.personCollectUserDao.queryById(collectUserId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<PersonCollectUser> queryAllByLimit(int offset, int limit) {
        return this.personCollectUserDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param personCollectUser 实例对象
     * @return 实例对象
     */
    @Override
    public PersonCollectUser insert(PersonCollectUser personCollectUser) {
        this.personCollectUserDao.insert(personCollectUser);
        return personCollectUser;
    }

    /**
     * 修改数据
     *
     * @param personCollectUser 实例对象
     * @return 实例对象
     */
    @Override
    public PersonCollectUser update(PersonCollectUser personCollectUser) {
        this.personCollectUserDao.update(personCollectUser);
        return this.queryById(personCollectUser.getCollectUserId());
    }

    /**
     * 通过主键删除数据
     *
     * @param collectUserId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer collectUserId) {
        return this.personCollectUserDao.deleteById(collectUserId) > 0;
    }
}